package gui;
import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JCheckBox;
import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JTextField;

import entities.Client;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.ImageIcon;
import java.awt.Color;
import java.awt.Font;


public class ClientWindow extends JFrame {

	private JPanel contentPane;
	private JTextField searchPicTextField;

	

	/**
	 * Create the frame.
	 */
	public ClientWindow(final Client client) {
		setTitle("User Window");
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(250, 30, 800, 600);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		JButton btnPurchasedPictures = new JButton("Purshased pictures");
		btnPurchasedPictures.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		btnPurchasedPictures.setForeground(new Color(0, 128, 0));
		btnPurchasedPictures.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				//PurchasedPictures purchasedPicFrame = new PurchasedPictures();
				//purchasedPicFrame.setVisible(true);
				ImageFrame imageFrame = new ImageFrame();
				imageFrame.setVisible(true);
			}
		});
		btnPurchasedPictures.setBounds(37, 246, 163, 29);
		contentPane.add(btnPurchasedPictures);
		
		JButton btnUserWindowSearch = new JButton("Search ");
		btnUserWindowSearch.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		btnUserWindowSearch.setForeground(new Color(0, 128, 0));
		btnUserWindowSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				String searchResultFrame = new String();
				searchResultFrame = searchPicTextField.getText();
				if (searchResultFrame.isEmpty())
					JOptionPane.showMessageDialog(null, "Search field is empyt pleas enter text to search");
				else {
					SearchResult seacrhFrame = new SearchResult();
					seacrhFrame.setVisible(true);
				}
				
			}
		});
		btnUserWindowSearch.setBounds(408, 38, 117, 29);
		contentPane.add(btnUserWindowSearch);
		
		searchPicTextField = new JTextField();
		searchPicTextField.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		searchPicTextField.setForeground(new Color(0, 128, 0));
		searchPicTextField.setBounds(264, 38, 134, 28);
		contentPane.add(searchPicTextField);
		searchPicTextField.setColumns(10);
		
		JLabel lblSearchPicture = new JLabel("Picture Search ");
		lblSearchPicture.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		lblSearchPicture.setForeground(new Color(0, 128, 0));
		lblSearchPicture.setBounds(282, 18, 98, 14);
		contentPane.add(lblSearchPicture);
		
		JButton btnBuyASubscription = new JButton("Buy a subscription");
		btnBuyASubscription.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		btnBuyASubscription.setForeground(new Color(0, 128, 0));
		btnBuyASubscription.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				BuyASubscribtion buyASubscribtionFrame = new BuyASubscribtion();
				buyASubscribtionFrame.setVisible(true);
				
			}
		});
		btnBuyASubscription.setBounds(37, 287, 163, 29);
		contentPane.add(btnBuyASubscription);
		
		JButton btnMyAccount = new JButton("My account");
		btnMyAccount.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		btnMyAccount.setForeground(new Color(0, 128, 0));
		btnMyAccount.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				MyAccount myAccountFrame = new MyAccount(client);
				myAccountFrame.setVisible(true);
			}
		});
		btnMyAccount.setBounds(63, 367, 117, 29);
		contentPane.add(btnMyAccount);
		
		JButton btnSendReport = new JButton("Send a report");
		btnSendReport.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		btnSendReport.setForeground(new Color(0, 128, 0));
		btnSendReport.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Report reprtframe = new Report();
				reprtframe.setVisible(true);
			}
		});
		btnSendReport.setBounds(53, 327, 130, 29);
		contentPane.add(btnSendReport);
		
		JButton btnLogOut = new JButton("Log Out");
		btnLogOut.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		btnLogOut.setForeground(new Color(0, 128, 0));
		btnLogOut.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				MainWindow mainWindowFrame = new MainWindow();
				mainWindowFrame.setVisible(true);
				dispose();
			}
		});
		btnLogOut.setBounds(632, 37, 117, 29);
		contentPane.add(btnLogOut);
		
		JButton btnInbox = new JButton("Inbox ");
		btnInbox.setFont(new Font("Palatino Linotype", Font.BOLD, 13));
		btnInbox.setForeground(new Color(0, 128, 0));
		btnInbox.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				ResolutionCenter resolutionCenter = new ResolutionCenter();
				resolutionCenter.setVisible(true);
			}
		});
		btnInbox.setBounds(73, 407, 98, 29);
		contentPane.add(btnInbox);
		
		JLabel lblWinowClientPic = new JLabel("");
		lblWinowClientPic.setIcon(new ImageIcon(ClientWindow.class.getResource("/FramePictures/1 (4).jpg")));
		lblWinowClientPic.setBounds(0, 0, 800, 578);
		contentPane.add(lblWinowClientPic);
	}
}
